<?php $this->beginBlock('header'); ?>
<link href="css/chess.css" type="text/css" rel="stylesheet" />
<script src="js/board.js"></script>
<script src="js/position.js"></script>
<script src="js/search.js"></script>
<script src="js/book.js"></script>
<?php $this->endBlock(); ?>
<div style="text-align:center;white-space:nowrap">
<span class="td" style="margin-right:10px;display:inline-block;">
  <div id="containerboard"></div>
</span>
<div style="text-align:left;vertical-align:top;display:inline-block;">
  <div class="label">谁先走</div>
  <div><select id="selMoveMode" size="3">
    <option selected value="0">我先走</option>
    <option value="1">电脑先走</option>
    <option value="2">不用电脑</option>
  </select></div>
  <div class="label">先走让子</div>
  <div><select id="selHandicap" style="padding:0px">
    <option selected value="0">不让子</option>
    <option value="1">让左马</option>
    <option value="2">让双马</option>
    <option value="3">让九子</option>
  </select></div>
  <div style="padding-top:2px"><input type="button" class="button" value="重新开始" onclick="restart_click()"></div>
  <div style="padding-top:2px"><input type="button" class="button" value="悔棋" onclick="retract_click()"></div>
</div>
<script type="text/javascript">
"use strict";

// 可供选择的开局局面
var STARTUP_FEN = [
  "rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKABNR w",
  "rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/RNBAKAB1R w",
  "rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/P1P1P1P1P/1C5C1/9/R1BAKAB1R w",
  "rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/9/1C5C1/9/RN2K2NR w",
];

var board = new Board(containerboard, "img/chess/");	// 实例化棋盘对象
board.setSearch(16);								// 设置搜索算法
board.computer = 1;									// 电脑默认执黑

// 重新开始
function restart_click() {
  board.computer = 1 - selMoveMode.selectedIndex;			// 根据用户选择，决定电脑执黑还是执红
  board.restart(STARTUP_FEN[selHandicap.selectedIndex]);	// 使用用户选择的开局局面，初始化棋局
}

// 悔棋
function retract_click() {
  board.retract();
}
</script>

<?php $this->beginBlock('js-bottom'); ?>

<?php $this->endBlock(); ?>